package org.googlecode.openapi_java;

import org.json.JSONException;
import org.json.JSONObject;

public class Media {
	private String type;
	private String itemId;
	// for all except graffiti
	private long ownerId;
	// for all except audio and video
	private String thumbSrc;
	// only for apps
	private long appId;

	public static Media fromJSON(JSONObject jMedia) throws JSONException{
		Media media = new Media();
		media.type = jMedia.getString("type");
		media.itemId = jMedia.getString("item_id");
		if (jMedia.has("owner_id")) media.ownerId = jMedia.getLong("owner_id");
		if (jMedia.has("thumb_src")) media.thumbSrc = jMedia.getString("thumb_src");
		if (jMedia.has("app_id")) media.appId = jMedia.getLong("app_id");
		return media;
	}
	
	
	public String getType() {
		return type;
	}
	public String getItemId() {
		return itemId;
	}
	public long getOwnerId() {
		return ownerId;
	}
	public String getThumbSrc() {
		return thumbSrc;
	}
	public long getAppId() {
		return appId;
	}
	
	
	
}
